'use strict';
const sqlite3 = require("sqlite3").verbose()

let dbcache = {};

module.exports.DB = function(req){
    let db;
    if(req.SITE.log in dbcache) return dbcache[req.SITE.log];
    if(req.SITE.db){
        db = new sqlite3.Database(req.SITE.db, (err)=>{
            if(err) console.log("database error", err);
        })
    }
    dbcache[req.SITE.log] = db;
    return db;
}